package com.myk.game.heroscuffle.game;

import com.myk.game.heroscuffle.heroes.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 英雄工厂类，以后新英雄都往这里注册
 */
public class HeroSchool {

    //注册英雄容器
    private final List<Hero> allHeroes;

    /**
     * 初始化英雄工厂类（可使用的英雄都在此注册）
     */
    public HeroSchool() {
        allHeroes = new ArrayList<>();
        allHeroes.add(new Hero_AoXue());
        allHeroes.add(new Hero_CangLang());
        allHeroes.add(new Hero_ChiLian());
        allHeroes.add(new Hero_FeiLian());
        allHeroes.add(new Hero_FengLing());
        allHeroes.add(new Hero_HuaYue());
        allHeroes.add(new Hero_JingYa());
        allHeroes.add(new Hero_JuShan());
        allHeroes.add(new Hero_KuMeng());
        allHeroes.add(new Hero_LinLin());
        allHeroes.add(new Hero_MoYan());
        allHeroes.add(new Hero_NanKe());
        allHeroes.add(new Hero_ShuiQing());
        allHeroes.add(new Hero_MuBai());
        allHeroes.add(new Hero_XiaoYin());
        allHeroes.add(new Hero_XiaZhan());
        allHeroes.add(new Hero_YouLan());
    }

    /**
     * 随机获取一个英雄，并从集合中移除
     */
    public Hero randomTakeHero() {
        if (allHeroes.size() > 0) {
            int index = (int) (Math.random() * allHeroes.size());
            Hero summonHero = allHeroes.get(index);
            allHeroes.remove(index);
            return summonHero;
        }
        else {
            return null;
        }
    }
}
